Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Programmer's Overview / Part 1 - Getting Started With QuickDraw GX
Chapter 2 - A Quick & Easy Sample Program


A Quick Review of the Sample Program

As a quick review, to create, modify, draw, and print this shape, you can use this code:

/* shape object reference */
gxShape aCurveShape;
/* shape geometry definition */
gxCurve aCurveGeometry = {{ff(40), ff(120)},  /* first point */
                          {ff(100), ff(0)},   /* control point */
                          {ff(200), ff(120)}};/* last point */
/* color structure */
gxColor halfGray;
/* point structure for center point */
gxPoint curveCenter;
/* view port object reference */
gxViewPort aViewPort;
/* job object reference */
gxJob aPrintJob;
/* shape object refernce for picture to contain shape */
gxShape aPage;
/* Code to declare window pointer, initialize Macintosh  */
/* Toolbox, and create window goes here. */
halfGray.space = gxGraySpace;   /* color space is grayspace */
halfGray.profile = nil;         /* no color-matching */
halfGray.element.gray = 0x8000; /* 50% intensity */
/* create and draw shape */
aCurveShape = GXNewShape(gxCurveType);
GXSetCurve(aCurveShape, &aCurveGeometry);
GXSetShapePen(aCurveShape, ff(10));
GXSetShapeColor(aCurveShape, &halfGray);
GXSetShapeAttributes(aCurveShape, gxMapTransformShape);
GXGetShapeCenter(aCurveShape, 0, &curveCenter);
GXRotateShape(aCurveShape, ff(45), curveCenter.x, curveCenter.y);
aViewPort = GXGetNewWindowViewPort(theWindow);
GXSetShapeViewPorts(aCurveShape, 1, &aViewPort);
GXDrawShape(aCurveShape);
/* print shape */
GXInitPrinting();
GXNewJob(&aPrintJob);
aPage = GXNewShape(gxPictureType);
GXSetPicture(aPage, 1, &aCurveShape, nil, nil, nil);
GXStartJob(aPrintJob, "\p Rotated Gray Curve ", 1);
GXPrintPage(aPrintJob, 1, GXGetJobFormat(aPrintJob, 1), aPage);
GXFinishJob(aPrintJob);
GXDisposeShape(aPage);
GXDisposeJob(aPrintJob);
GXExitPrinting();
GXDisposeShape(aCurveShape);
This simple example shows only the smallest percentage of the features provided by shape, style, ink, and transform objects. The next chapter
discusses more of the features of these objects and the functions that manipulate them, but even that chapter gives only part of the picture! You
can find a complete reference to the features, structures, object types, and functions of QuickDraw GX in the other books of the Inside Macintosh QuickDraw GX suite.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996